import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store'
import ElementUI from 'element-ui'
// import DictData from "@/components/DictData/index"
import './assets/styles/elementTheme/theme/index.css'
// import 'element-ui/lib/theme-chalk/index.css';
// import 'umy-ui/lib/theme-chalk/index.css'
import directive from './directive' // directive

import * as echarts from 'echarts';
Vue.prototype.$echarts = echarts

import website from './plugins/config/website'
Vue.prototype.$website = website
import FISH from '@/utils/auth.js'
Vue.prototype.$FISH = FISH
import Bus from './bus'
Vue.use(Bus)

import './assets/styles/index.less'
import '@/assets/iconfont/iconfont.css';
import './utils/svg'
import './public-path'
import './comp'
import './permission'
import Mixin from './mixins'

Vue.config.productionTip = false;

let instance = null;
const elementId = process.env.VUE_APP_NAME

Vue.mixin(Mixin)
Vue.use(ElementUI);
Vue.use(directive);
// DictData.install();

function render(props = {}) {
  const { container } = props;
  instance = new Vue({
    router,
    store,
    render: h => h(App),
  }).$mount(container ? container.querySelector(`#${elementId}`) : `#${elementId}`);
}
// 独立运行
if (!window.__POWERED_BY_QIANKUN__) {
  render();
}
// 生命周期钩子必须返回promise
// 渲染之前
export async function bootstrap() {
  console.log('[vue] vue app bootstraped');
}

// 渲染函数
export async function mount(props) {
  render(props);
}

// 卸载函数
export async function unmount() {
  instance.$destroy();
  instance.$el.innerHTML = '';
  instance = null;
}
